package LeetCode;

public class LC_669_TrimaBinarySearchTree {

    public static void main(String[] args) {

    }

    class Solution {
        TreeNode trimBST(TreeNode root, int L, int R) {
            if (root == null) return null;
            if (root.val >= L && root.val <= R) {
                root.left = trimBST(root.left, L, R);
                root.right = trimBST(root.right, L, R);
                return root;
            }
            if (root.val < L)
                return trimBST(root.right, L, R);
            return trimBST(root.left, L, R);
        }
    }

}